<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">
    <title>提现</title>
    <link href="${pageContext.request.contextPath}/assets/css/demo.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/assets/css/amazeui.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/assets/css/personal.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/assets/css/stepstyle.css" rel="stylesheet" type="text/css">
    <script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/assets/js/amazeui.js"></script>
    <style type="text/css">
        body {
            /*background-color: #fff;*/
        }

        .cash_div {
            background-color: #fff;
            margin-top: 2%;
            margin-bottom: 3%;

        }

        .cash_input {

            width: 100%;
            height: 35px;
            font-size: 15px;
            padding-left: 4%;
            border: 0;
        }

        ::-webkit-input-placeholder { /* WebKit browsers */
            color: #5c5c5c;
            font-size: 15px;
        }

        :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: #5c5c5c;
            font-size: 15px;
        }

        ::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: #5c5c5c;
            font-size: 15px;
        }

        :-ms-input-placeholder { /* Internet Explorer 10+ */
            color: #5c5c5c;
            font-size: 15px;
        }

    </style>
</head>

<body>
<div class="center">
    <div class="">
        <div>
            <div class="am-cf am-padding" style="margin-bottom: 10px; background-color:#fff">
                <div class="am-fl am-cf" style="float: none;text-align: center;margin: 2%"><strong
                        class="am-text-danger am-text-lg" style="font-size: 23px;">余额提现</strong>
                </div>
            </div>
            <!--<hr/>-->
            <form>
                <!--<span>当前佣金</span><span style="float: right">{$user_money}</span>-->

                <!--<div class="am-form-group" style="background-color: #fff">-->
                <!--<label for="money" style="font-size: 18px;font-weight: bold;margin-bottom: 10px;"></label>-->
                <div class="cash_div">
                    <input class="cash_input" type="text" id="bank_name" placeholder="请输入开户行"/>
                </div>
                <div class="cash_div">
                    <!--<div class="am-form-group">-->
                    <!--<label for="account_bank" style="font-size: 18px;font-weight: bold;margin-bottom: 10px;"></label>-->
                    <input type="text" class="cash_input" id="account_bank" placeholder="请输入银行卡号"/>
                </div>
                <div class="cash_div">
                    <!--<div class="am-form-group">-->
                    <!--<label for="money" style="font-size: 18px;font-weight: bold;margin-bottom: 10px;"></label>-->
                    <input type="text" class="cash_input" id="account_name" placeholder="请输入持卡人姓名"/>
                </div>
                <div class="cash_div">
                    <!--<div class="am-form-group">-->
                    <!--<label for="money" style="font-size: 18px;font-weight: bold;margin-bottom: 10px;"></label>-->
                    <input type="text" class="cash_input" id="phone" placeholder="请输入联系方式"/>
                </div>
                <div class="cash_div">
                    <!--<div class="am-form-group">-->
                    <!--<label for="money" style="font-size: 18px;font-weight: bold;margin-bottom: 10px;"></label>-->
                    <span style="font-size: 15px;color: #5c5c5c;padding-left: 4%">提现金额</span>

                    <span style="position: relative;right: 19%;top:56px;font-size: 35px">￥</span>

                    <div style="margin-left: 10%;margin-top: 4%; margin-bottom: 4%">

                        <input type="text"
                               style="height: 35px;font-size: 25px;padding:10px;border-bottom:solid;border-bottom-color: #999;border-bottom-width:1px"
                               class="cash_input" id="money"/>

                    </div>
                    <span style="color: red;font-size: 15px;padding-left: 4%;">最低提现金额：${money}元</span><br/>
                    <span style="font-size: 15px;color: #5c5c5c;padding-left: 4%">可提金额：${user.money}元</span><br/>
                    <br/>
                </div>
                <div class="am-u-sm-12" align="center">
                    <button type="button" onclick="returnGoods()" class="am-btn am-round"
                            style="background-color: #ED6D00;color: #fff;width:100%;margin-top: 15px">确认提现
                    </button>
                </div>
                <div class="am-u-sm-12" align="center" style="font-size: 16px;margin-top: 20px;">
                    提交成功后，1-3个工作日处理完成
                </div>
            </form>
        </div>
    </div>
</div>
</body>

</html>
<script type="text/javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script>
<script>
    function modalInfo(info, success) {
        layer.msg(info);
    }

    function returnGoods() {
        var reg = new RegExp("^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$");
        var money = $("#money").val();
        var bank_name = $('#bank_name').val();
        var account_bank = $('#account_bank').val();
        var account_name = $('#account_name').val();
        var phone = $('#phone').val();
        if (bank_name == '' || account_bank == '' || account_name == '' || phone == '') {
            modalInfo('请完善信息！', false);
            return;
        }

        if (!money || !reg.test(money) || money < 0) {
            modalInfo('请输入金额！', false);
            return;
        }
        $.ajax({
            type: 'POST',
            url: "${pageContext.request.contextPath}/clientWithdraw/add",
            dataType: 'json',
            data: {
                money: money,
                name: bank_name,
                blank: account_bank,
                account: account_name,
                phone: phone
            },
            success: function (data) {
                if (data.success) {
                    setInterval(function () {
                        window.location.href = "${pageContext.request.contextPath}/clientHome/goWithdrawalList"
                    }, 2000);
                    layer.msg('提现成功,2秒后自动返回。');
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function (data) {
                modalInfo('服务器繁忙！', false);
            }
        });
    }
</script>